#include "Interpolation.h"
#include <iostream>
#include <cmath>

using namespace std;

const double pi = acos(-1);

double f(double input)
{
  return 1 / (1 + 25 * input*input);
};

int main()
{
  freopen("./data/C.txt","w",stdout); 
  for (int n = 5; n <= 20; n += 5)
    {
      vector<double> x,y;
      for (double i = 0; i < n; i++)
	{
	  x.push_back(cos(pi*(2*i+1)/(2*n)));
	  y.push_back(f(x[i]));
	}
      Newton_formula Newton(x,y);
      for (double i = -1; i <= 1; i += 0.01)
	{
	  printf("%lf,",Newton.operate(i));
	}
      puts("");
    }
  for (double i = -1; i <= 1; i += 0.01)
    {
      printf("%lf,",f(i));
    }
  fclose(stdout);
  return 0;
}
